from flask import Flask
from riversr.controller.file import bp as bp_api_file
from riversr.controller.river import bp as bp_api_river
from riversr.controller.rule import bp as bp_api_rule
from riversr.controller.test import bp as bp_api_test
from flask_cors import CORS

app=Flask(__name__)

# 解决跨域问题
CORS(app, resources=r'/*')	# 注册CORS, "/*" 允许访问所有api

import config
from exts import db
# 指定配置文件
app.config.from_object(config)
# 可以先创建再绑定
db.init_app(app)

# 注册blueprint
app.register_blueprint(bp_api_file)
app.register_blueprint(bp_api_river)
app.register_blueprint(bp_api_rule)
app.register_blueprint(bp_api_test)

if __name__=='__main__':
    app.run(host="0.0.0.0", debug=False,port=5555)